﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include "ISurface.h"
#include "GbmpConstants.h"
#include "Intervald.h"


namespace gcmp
{
    class Coordinate3d;

    /// \brief 平面
    ///
    class IPlane : public ISurface
    {
        DEFINE_CAST_DERIVED(gcmp::IPlane, gcmp::ISurface);
    public:
        /// \brief  根据空间中一点和以该点为原点的右手坐标系，以及U、V向参数域构造平面
        /// \param  point           空间中一点
        /// \param  xDirection            XOY平面的x轴方向
        /// \param  yDirection            XOY平面的y轴方向
        /// \param  intervalU       U向参数域
        /// \param  intervalV       V向参数域
        /// \return  平面
        GCMP_GEOMETRY_INTERFACE_EXPORT static OwnerPtr<IPlane> Create(
            const Vector3d& point,
            const Vector3d& xDirection,
            const Vector3d& yDirection,
            const Intervald& intervalU = Intervald(Constants::MATH_NEGINFINITY, Constants::MATH_INFINITY),
            const Intervald& intervalV = Intervald(Constants::MATH_NEGINFINITY, Constants::MATH_INFINITY)
        );

        /// \brief  根据空间中一点和法向量，以及U、V向参数域构造平面
        /// \param  point           空间中一点
        /// \param  normal          法向量
        /// \param  intervalU       U向参数域
        /// \param  intervalV       V向参数域
        /// \return  平面
        GCMP_GEOMETRY_INTERFACE_EXPORT static OwnerPtr<IPlane> Create(
            const Vector3d& point,
            const Vector3d& normal,
            const Intervald& intervalU = Intervald(Constants::MATH_NEGINFINITY, Constants::MATH_INFINITY),
            const Intervald& intervalV = Intervald(Constants::MATH_NEGINFINITY, Constants::MATH_INFINITY)
        );


    public:
        
        /// \brief  设置平面的基点
        /// \param  origin 平面的基点
        /// \return 成功返回true,否则返回false(默认返回True)
        virtual bool SetOrigin(const Vector3d& origin) = 0;

        /// \brief  获取平面的基点
        /// \return 基点
        virtual Vector3d GetOrigin() const = 0;

        /// \brief  获取平面U向单位化方向
        /// \return U向单位化方向
        virtual Vector3d GetDirectionU() const = 0;
        
        /// \brief  获取平面V向单位化方向
        /// \return V向单位化方向
        virtual Vector3d GetDirectionV() const = 0;
        
        /// \brief  获取平面法向
        /// \return 法向
        virtual Vector3d GetNormal() const = 0;

        /// \brief  获得坐标系
        /// \return 坐标系
        virtual Coordinate3d GetCoordinate() const = 0;

        /// \brief 通过坐标系的XOY平面设置自身
        /// \param coordinate3d 坐标系
        /// \return 成功返回true,否则返回false(默认返回True)
        virtual bool SetCoordinate(const Coordinate3d &coordinate3d) = 0;
    
        /// \brief 设置U向参数范围
        /// \param intervalU U向参数范围
        /// \return 成功返回true,否则返回false(默认返回True)
        virtual bool SetLimitU(const Intervald& intervalU) = 0;

        /// \brief     设置V向参数范围
        /// \param intervalV V向参数范围
        /// \return 成功返回true,否则返回false(默认返回True)
        virtual bool SetLimitV(const Intervald& intervalV) = 0;

        /// \brief  对平面进行反向
        /// \return 成功返回true,否则返回false(默认返回True)
        virtual bool Negate() = 0;

    public:
        virtual ~IPlane() {}
    };
}
